/*
 * 创建日期 2005-10-25
 *
 * 功能： 个人事务 --> 日历控件
 * 
 */
package com.wjf.birdfish.util;

import java.io.IOException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.servlet.jsp.JspWriter;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 * 说明: 个人事务 --> 日历控件 <p>
 *
 * @author   
 * @author   
 * @version  1.0
 * Company   http://www.tydic.com
 */
public class LTOACalendar
{
    class MyCalendarMonth
    {

        calElement DObj[];
        int firstWeek;

        void SetCal(int ilength)
        {
            DObj = new calElement[ilength];
            for(int i = 0; i < DObj.length; i++)
             DObj[i] = new calElement();

        }

        MyCalendarMonth(int y, int m)
        {
            int lY;
            int lM;
            int lD;
            int lX;
            boolean lL;
            String cY;
            String cM;
            int lDPOS[];
            int n;
            Date sDObj;
            int length;
            int term2;
            int firstNode;
            int dayCyclical;
            int j;
            DObj = null;
            m--;
            lY = 0;
            lM = 0;
            lD = 1;
            lX = 0;
            lL = false;
            lDPOS = new int[3];
            n = 0;
            int firstLM = 0;
            sDObj = null;
            sDObj = new Date(y - 1900, m, 1, 0, 0, 0);
            length = solarDays(y, m);
            SetCal(length);
            firstWeek = sDObj.getDay();
            if(m < 2){
                cY = cyclical((y - 1900) + 36);
            }else {
                cY = cyclical((y - 1900) + 36);
            }
            term2 = sTerm(y, 2);
            firstNode = sTerm(y, m * 2);
            cM = cyclical((y - 1900) * 12 + m + 12);
            dayCyclical = (int)(Date.UTC(y, m, 1, 0, 0, 0) / 0x5265c00L) + 25567 + 10;
            j = 0;
            if(j < length){
            	
            
               String m_strD;
            sDObj = new Date(y, m, j + 1, 0, 0, 0);
            if(lD > lX)
            {
                Lunar lDObj = new Lunar(sDObj);
                lY = lDObj.year;
                lM = lDObj.month;
                lD = lDObj.day;
                lL = lDObj.isLeap;
                lX = lL ? leapDays(lY) : monthDays(lY, lM);
                if(n == 0)
                    firstLM = lM;
                lDPOS[n++] = (j - lD) + 1;
            }
            if(m == 1 && j + 1 == term2)
                cY = cyclical((y - 1900) + 36);
            if(j + 1 == firstNode)
                cM = cyclical((y - 1900) * 12 + m + 13);
            String cD = cyclical(dayCyclical + j);
            DObj[j].set(y, m + 1, j + 1, nStr1[(j + firstWeek) % 7], lY, lM, lD++, lL, cY, cM, cD);
            int tmp1 = sTerm(y, m * 2) - 1;
            int tmp2 = sTerm(y, m * 2 + 1) - 1;
            DObj[tmp1].solarTerms = solarTerm[m * 2];
            DObj[tmp2].solarTerms = solarTerm[m * 2 + 1];
            if(m == 3)
                DObj[j].color = "red ";
            m_strD = FormatDateTime(sDObj, "MMdd");
            for(int i = 0; i < sFtv.length; i++)
            {
                if(sFtv[i].indexOf(m_strD) >= 0)
                {
                    if(sFtv[i].indexOf("*") >= 0)
                        DObj[j].color = "red";
                    DObj[j].solarFestival = sFtv[i].substring(5, sFtv[i].length());
                    break;
                }
            }

            m_strD = FormatNum(lM, 2) + FormatNum(lD - 1, 2);
            for(int i = 0; i < lFtv.length; i++)
            {
                if(lFtv[i].indexOf(m_strD) >= 0)
                {
                    if(lFtv[i].indexOf("*") >= 0)
                        DObj[j].color = "red";
                    DObj[j].lunarFestival = lFtv[i].substring(5, lFtv[i].length());
                    break;
                }
              }
         } 
         if((firstWeek + 12) % 7 != 5 || j != 12) {
                int i;
                Date sDMObj = new Date(y, m, 1, 0, 0, 0);
                int iDays = DateDiff(sDObj, sDMObj, 2);
                int iWeek = iDays / 7 + 1;
                String m_strD = FormatNum(lM, 2) + FormatNum(iWeek, 2) + FormatNum((j + firstWeek) % 7, 1);
                i = 0;
                if(i < wFtv.length){ 
                      if(sFtv[i].indexOf("*") >= 0)
                          DObj[j].color = "red";
                      new StringBuffer();
                      wFtv[i].substring(5, wFtv[i].length());
                      toString();
                      i++;
                } else {
                	 j++;
                }

            } else {
                new StringBuffer();
                toString();
            }
           
        }
    }

    class calElement
    {

        public String cDay;
        public String cMonth;
        public String cYear;
        public String color;
        public boolean isLeap;
        public boolean isToday;
        public int lDay;
        public int lMonth;
        public int lYear;
        public String lunarFestival;
        public int sDay;
        public int sMonth;
        public int sYear;
        public String solarFestival;
        public String solarTerms;
        public String week;

        void set(int sYear, int sMonth, int sDay, String week, int lYear, int lMonth, int lDay, 
                boolean isLeap, String cYear, String cMonth, String cDay)
        {
            isToday = false;
            this.sYear = sYear;
            this.sMonth = sMonth;
            this.sDay = sDay;
            this.week = week;
            this.lYear = lYear;
            this.lMonth = lMonth;
            this.lDay = lDay;
            this.isLeap = isLeap;
            this.cYear = cYear;
            this.cMonth = cMonth;
            this.cDay = cDay;
            color = "";
            lunarFestival = "";
            solarFestival = "";
            solarTerms = "";
        }

        calElement()
        {
        }
    }

    class Lunar
    {

        int day;
        boolean isLeap;
        int month;
        int year;

        Lunar(Date objDate)
        {
            int leap = 0;
            int temp = 0;
            long baseDate = Date.UTC(1900, 0, 30, 0, 0, 0);
            long offset = 0L;
            int j = objDate.getYear();
            offset = (Date.UTC(objDate.getYear(), objDate.getMonth(), objDate.getDate(), 0, 0, 0) - baseDate) / 0x5265c00L;
            int i;
            for(i = 1900; i < 2100 && offset > 0L; i++)
            {
                temp = lYearDays(i);
                offset -= temp;
            }

            if(offset < 0L)
            {
                offset += temp;
                i--;
            }
            year = i;
            leap = leapMonth(i);
            isLeap = false;
            for(i = 1; i < 13 && offset > 0L; i++)
            {
                if(leap > 0 && i == leap + 1 && !isLeap)
                {
                    i--;
                    isLeap = true;
                    temp = leapDays(year);
                } else
                {
                    temp = monthDays(year, i);
                }
                if(isLeap && i == leap + 1)
                    isLeap = false;
                offset -= temp;
            }

            if(offset == 0L && leap > 0 && i == leap + 1)
                if(isLeap)
                {
                    isLeap = false;
                } else
                {
                    isLeap = true;
                    i--;
                }
            if(offset < 0L)
            {
                offset += temp;
                i--;
            }
            month = i;
            day = (int)offset + 1;
        }
    }


    String Animals[] = {
        "鼠", "牛", "虎", "兔", "龙", "蛇", "马", "羊", "猴", "鸡", 
        "狗", "猪"
    };
    String Gan[] = {
        "甲", "乙", "丙", "丁", "戊", "己", "庚", "辛", "壬", "癸"
    };
    String Zhi[] = {
        "子", "丑", "寅", "卯", "辰", "巳", "午", "未", "申", "酉", 
        "戌", "亥"
    };
    String lFtv[] = {
        "0101*春节", "0115 元宵节", "0202 龙抬头节", "0323 妈祖生辰 (天上圣母诞辰)", "0505 端午节", "0707 七七中国情人节", "0815 中秋节", "0909 重阳节", "1208 腊八节", "1223 腊八节", 
        "0100*除夕"
    };
    int lunarInfo[] = {
        19416, 19168, 42352, 21717, 53856, 55632, 21844, 22191, 39632, 21970, 
        19168, 42422, 42192, 53840, 53909, 46415, 54944, 44450, 38320, 18807, 
        18815, 42160, 46261, 27216, 27968, 43860, 11119, 38256, 21234, 18800, 
        25958, 54432, 59984, 27285, 23263, 11104, 34531, 37615, 51415, 51551, 
        54432, 55462, 46431, 22176, 42420, 9695, 37584, 53938, 43344, 46423, 
        27808, 46416, 21333, 19887, 42416, 17779, 21183, 43432, 59728, 27296, 
        44710, 43856, 19296, 43748, 42352, 21088, 62051, 55632, 23383, 22176, 
        38608, 19925, 19152, 42192, 54484, 53840, 54616, 46400, 46752, 38310, 
        38335, 18864, 43380, 42160, 45690, 27216, 27968, 44870, 43872, 38256, 
        19189, 18800, 25776, 29859, 59984, 27480, 23232, 43872, 38613, 37600, 
        51552, 55636, 54432, 55888, 30034, 22176, 43959, 9680, 37584, 51893, 
        43344, 46240, 47780, 44368, 21977, 19360, 42416, 20854, 21183, 43312, 
        31060, 27296, 44368, 23378, 19296, 42726, 42208, 53856, 60005, 54576, 
        23200, 30371, 38608, 19195, 19152, 42192, 53430, 53855, 54560, 56645, 
        46496, 22224, 21938, 18864, 42359, 42160, 43600, 45653, 27951, 44448, 
        19299, 37759, 18936, 18800, 25776, 26790, 59999, 27424, 42692, 43759, 
        37600, 53987, 51552, 54615, 54432, 55888, 23893, 22176, 42704, 21972, 
        21200, 43448, 43344, 46240, 46758, 44368, 21920, 43940, 42416, 21168, 
        45683, 26928, 29495, 27296, 44368, 19285, 19311, 42352, 21732, 53856, 
        59752, 54560, 55968, 27302, 22239, 19168, 43476, 42192, 53584, 62034, 
        54560
    };
    String monthName[] = {
        "1 月", "2 月", "3 月", "4 月", "5 月", "6 月", "7 月", "8 月", "9 月", "10 月", 
        "11 月", "12 月"
    };
    String nStr1[] = {
        "日", "一", "二", "三", "四", "五", "六", "七", "八", "九", 
        "十"
    };
    String nStr2[] = {
        "初", "十", "廿", "卅", "　"
    };
    String sFtv[] = {
        "0101*元旦", "0214 情人节", "0308 妇女节", "0312 植树节", "0315 消费者权益日", "0401 愚人节", "0501 劳动节", "0504 青年节", "0512 护士节", "0601 儿童节", 
        "0701 建党节 香港回归纪念", "0801 建军节", "0808 父亲节", "0909 毛泽东逝世纪念", "0910 教师节", "0928 孔子诞辰", "1001*国庆节", "1006 老人节", "1024 联合国日", "1112 孙中山诞辰纪念", 
        "1220 澳门回归纪念", "1225 圣诞节", "1226 毛泽东诞辰纪念"
    };
    String sFtv1[] = {
        "0101*新年元旦", "0202 世界湿地日", "0207 国际声援南非日", "0210 国际气象节", "0214 情人节", "0301 国际海豹日", "0303 全国爱耳日", "0308 国际妇女节", "0312 植树节 孙中山逝世纪念日", "0314 国际警察日", 
        "0315 国际消费者权益日", "0317 中国国医节 国际航海日", "0321 世界森林日 消除种族歧视国际日", "0321 世界儿歌日", "0322 世界水日", "0323 世界气象日", "0324 世界防治结核病日", "0325 全国中小学生安全教育日", "0330 巴勒斯坦国土日", "0401 愚人节 全国爱国卫生运动月(四月) 税收宣传月(四月)", 
        "0407 世界卫生日", "0422 世界地球日", "0423 世界图书和版权日", "0424 亚非新闻工作者日", "0501 国际劳动节", "0504 中国五四青年节", "0505 碘缺乏病防治日", "0508 世界红十字日", "0512 国际护士节", "0515 国际家庭日", 
        "0517 世界电信日", "0518 国际博物馆日", "0520 全国学生营养日", "0523 国际牛奶日", "0531 世界无烟日", "0601 国际儿童节", "0605 世界环境日", "0606 全国爱眼日", "0617 防治荒漠化和干旱日", "0623 国际奥林匹克日", 
        "0625 全国土地日", "0626 国际反毒品日", "0701 中国共产党建党日 世界建筑日", "0702 国际体育记者日", "0707 中国人民抗日战争纪念日", "0711 世界人口日", "0730 非洲妇女日", "0801 中国建军节", "0808 中国男子节(爸爸节)", "0815 日本正式宣布无条件投降日", 
        "0908 国际扫盲日 国际新闻工作者日", "0910 教师节", "0914 世界清洁地球日", "0916 国际臭氧层保护日", "0918 九\267一八事变纪念日", "0920 国际爱牙日", "0927 世界旅游日", "1001*国庆节 世界音乐日 国际老人节", "1001 国际音乐日", "1002 国际和平与民主自由斗争日", 
        "1004 世界动物日", "1008 全国高血压日", "1008 世界视觉日", "1009 世界邮政日 万国邮联日", "1010 辛亥革命纪念日 世界精神卫生日", "1013 世界保健日 国际教师节", "1014 世界标准日", "1015 国际盲人节(白手杖节)", "1016 世界粮食日", "1017 世界消除贫困日", 
        "1022 世界传统医药日", "1024 联合国日 世界发展信息日", "1031 世界勤俭日", "1107 十月社会主义革命纪念日", "1108 中国记者日", "1109 全国消防安全宣传教育日", "1110 世界青年节", "1111 国际科学与和平周(本日所属的一周)", "1112 孙中山诞辰纪念日", "1114 世界糖尿病日", 
        "1117 国际大学生节 世界学生节", "1121 世界问候日 世界电视日", "1129 国际声援巴勒斯坦人民国际日", "1201 世界艾滋病日", "1203 世界残疾人日", "1205 国际经济和社会发展志愿人员日", "1208 国际儿童电视日", "1209 世界足球日", "1210 世界人权日", "1212 西安事变纪念日", 
        "1213 南京大屠杀(1937年)纪念日！紧记血泪史！", "1220 澳门回归纪念", "1221 国际篮球日", "1224 平安夜", "1225 圣诞节", "1226 毛泽东诞辰纪念", "1229 国际生物多样性日"
    };
    int sTermInfo[] = {
        0, 21208, 42467, 63836, 0x14d59, 0x1a206, 0x1f763, 0x24d89, 0x2a45d, 0x2fbdf, 
        0x353d8, 0x3ac35, 0x404af, 0x45d25, 0x4b553, 0x50d19, 0x56446, 0x5bac6, 0x61087, 0x6658a, 
        0x6b9db, 0x70d90, 0x760cc, 0x7b3b6
    };
    int solarMonth[] = {
        31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 
        30, 31
    };
    String solarTerm[] = {
        "小寒", "大寒", "立春", "雨水", "惊蛰", "春分", "清明", "谷雨", "立夏", "小满", 
        "芒种", "夏至", "小暑", "大暑", "立秋", "处暑", "白露", "秋分", "寒露", "霜降", 
        "立冬", "小雪", "大雪", "冬至"
    };
    String wFtv[] = {
        "0110 黑人日", "0150 世界麻风日", "0520 国际母亲节", "0530 全国助残日", "0630 父亲节", "0911 劳动节", "0932 国际和平日", "0940 国际聋人节 世界儿童日", "0950 世界海事日", "1011 国际住房日", 
        "1013 国际减轻自然灾害日(减灾日)", "1144 感恩节"
    };

    public LTOACalendar(){}

    public int DateDiff(Date calBegin, Date calEnd, int iType)
    {
        long lBegin = calBegin.getTime();
        long lEnd = calEnd.getTime();
        int ss = (int)((lBegin - lEnd) / 1000L);
        int min = ss / 60;
        int hour = min / 60;
        int day = hour / 24;
        if(iType == 0)
            return hour;
        if(iType == 1)
            return min;
        if(iType == 2)
            return day;
        else
            return -1;
    }

    public String FormatDateTime(Date dt, String strFormat)
    {
        SimpleDateFormat sdf = null;
        sdf = new SimpleDateFormat(strFormat);
        String sDateTime = sdf.format(dt);
        return sDateTime;
    }

    String FormatNum(int iNum, int iLen)
    {
        String m_strRet = String.valueOf(iNum);
        for(int i = 0; i < iLen - m_strRet.length(); i++)
            m_strRet = "0" + m_strRet;

        return m_strRet;
    }

    public String GetDayInfo(String m_strDate)
    {
        DateUtil dateUtil = new DateUtil();
        int Year = Integer.parseInt(dateUtil.FormatDateTime(m_strDate, "yyyy"));
        int iMonth = Integer.parseInt(dateUtil.FormatDateTime(m_strDate, "M"));
        int iD = Integer.parseInt(dateUtil.FormatDateTime(m_strDate, "d"));
        MyCalendarMonth M = new MyCalendarMonth(Year, iMonth);
        String s = "";
        if(iD - 1 < M.DObj.length)
        {
            String festival = "";
            if(M.DObj[iD - 1].solarTerms == "" && M.DObj[iD - 1].solarFestival == "" && M.DObj[iD - 1].lunarFestival == "")
                festival = "";
            else
                festival = "<TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=0 BGCOLOR='#CCFFCC'><TR><TD><FONT COLOR='#000000' STYLE='font-size:9pt;'>" + M.DObj[iD - 1].solarTerms + " " + M.DObj[iD - 1].solarFestival + " " + M.DObj[iD - 1].lunarFestival + "</FONT></TD>" + "</TR></TABLE>";
            s = "<TABLE WIDTH=130 BORDER=0 CELLPADDING=2 CELLSPACING=0 BGCOLOR=#000066><TR><TD><TABLE WIDTH=100% BORDER=0 CELLPADDING=0 CELLSPACING=0><TR><TD ALIGN=right><FONT COLOR='#99CCFF' STYLE='font-size:9pt;'>" + M.DObj[iD - 1].sYear + " 年 " + M.DObj[iD - 1].sMonth + " 月 " + M.DObj[iD - 1].sDay + " 日<br>星期" + M.DObj[iD - 1].week + "<br>" + "<font color='violet'>农历" + (M.DObj[iD - 1].isLeap ? "闰 " : " ") + M.DObj[iD - 1].lMonth + " 月 " + M.DObj[iD - 1].lDay + " 日</font><br>" + "<font color=yellow>" + M.DObj[iD - 1].cYear + "年 " + M.DObj[iD - 1].cMonth + "月 " + M.DObj[iD - 1].cDay + "日</font>" + "</FONT></TD></TR></TABLE>" + festival + "</TD></TR></TABLE>";
        }
        return s;
    }
 
    public String GetFDay(String m_strDate)
    {
        String m_strRet = "";
        String FS = "0101*元旦,0214 情人节,0308 妇女节,0312 植树节,0315 消费者权益日,0401 愚人节,0501 劳动节,0504 青年节,0509 郝维节,0512 护士节,0601 儿童节,0701 建党节 香港回归纪念,0801 建军节,0808 父亲节,0816 燕衔泥节,0909 毛泽东逝世纪念,0910 教师节,0928 孔子诞辰,1001*国庆节,1006 老人节,1024 联合国日,1112 孙中山诞辰纪念,1220 澳门回归纪念,1225 圣诞节,1226 毛泽东诞辰纪念";
        String m_strFList[] = FS.split(",");
        for(int i = 0; i < m_strFList.length; i++)
        {
            if(m_strFList[i].indexOf(m_strDate) == 0)
            {
                m_strRet = m_strFList[i].substring(5);
                break;
            }
        }

        //DateUtil dateUtil = new DateUtil();

//        m_strDate = DateUtil.GetDate();
        //dateUtil.getDay(m_strDate);
        return m_strRet;
    }

    public String GetLYearName(int SY)
    {
        String yDisplay = "";
        if(SY > 1874 && SY < 1909)
            yDisplay = "光绪" + (SY - 1874 != 1 ? String.valueOf(SY - 1874) : "元");
        if(SY > 1908 && SY < 1912)
            yDisplay = "宣统" + (SY - 1908 != 1 ? String.valueOf(SY - 1908) : "元");
        if(SY > 1911 && SY < 1950)
            yDisplay = "民国" + (SY - 1911 != 1 ? String.valueOf(SY - 1911) : "元");
        if(SY > 1948)
            yDisplay = "建国" + (SY - 1949 != 1 ? String.valueOf(SY - 1949) : "元");
        return yDisplay + "年 农历 " + cyclical((SY - 1900) + 36) + "年 【" + Animals[(SY - 4) % 12] + "年】";
    }

//    public void showCalendar(String userID, String calDate,JspWriter out) throws LTOAException, IOException{
//    	
//    	Log log = LogFactory.getLog( this.getClass());
//		Connection conn = null;
//        PreparedStatement pstmt = null;
//        ResultSet rs = null;
//        PoolingDataSource pool = null;
//        
//        String sql = null;
//		
//        out.println("<table align=center width=100% cellPadding=0 cellSpacing=0>");
//        out.println("<tr height=5px><td></td></tr>");
//        try {
//        	
//        	 sql = " SELECT * from LT_PER_CAL WHERE  UserID = ? and ( StartTime <= ? and EndTime >= ? ) ";
//        	 
//        	 pool = new PoolingDataSource();
//             conn = pool.getConnection();
//             pstmt = conn.prepareStatement(sql);
//             pstmt.setInt(1,Integer.parseInt(userID));
//             pstmt.setString(2,calDate);
//             pstmt.setString(3,calDate);
//             rs = pstmt.executeQuery();
//			 while(rs.next()){
//				 //out.println("</td></tr>");
//				 System.out.println("calDate:" + calDate);
//				 out.println("<tr>");
//				 //if(rs.getString("FinishFlag").equals("0")){
//				 //   out.println("<td width=14><img border=0 src='../images/crm_check.gif'></td>");
//				 //}  else {
//				    //out.println("<td></td>");
//				 //}
//				 if(rs.getString("ImportFlag").equals("0")){
//				     out.println("<td width=14><font color=red>★</font></td>");
//				 }  else {
//					 out.println("<td></td>");
//				 }
//			     out.println("<td style='font-size:12px;font-family:arial'>" + rs.getString("StartTime"));
//			     out.println("&nbsp;");
//			     out.println("<a href='perCalEdit.jsp?RecID=" + rs.getString("RecID") + "'>" + rs.getString("Title") + "</a>");
//				 out.println("</td></tr>");
//			 } 
//			 out.println("</table>");
//        } catch(SQLException sqle) {
//            log.error("错误 - 数据查询失败[ com.lztx.oa.util.LTOACalendar.showCalendar()]");
//            log.error("原因 - " + sqle.getMessage());
//             throw new LTOAException(LTOAException.ERR_DBOP_FAIL, "数据查询数据失败("
//                    + this.getClass().getName() + ".GetNameValueByRecID())", sqle);
//        } catch (ClassNotFoundException cfe) {
//            log.error("错误 - PoolingDataSource类不存在[ com.lztx.oa.dbutil.LTOACalendar.showCalendar()]");
//            log.error("原因 - " + cfe.getMessage());
//            throw new LTOAException(LTOAException.ERR_CLASS_NOTFOUND, "没有找到PoolingDataSource.java文件("
//                    + this.getClass().getName() + ".showCalendar())", cfe);
//        } catch (Exception e) {
//            log.error("错误 - 数据查询发生意外错误");
//            log.error("原因 - " + e.getMessage());
//            throw new LTOAException(LTOAException.ERR_UNKNOWN, "数据查询发生意外错误("
//                    + this.getClass().getName() + ".showCalendar())", e);
//        } finally {
//            pool.closeResultSet(rs);
//            pool.closePrepStmt(pstmt);
//            pool.closeConnection(conn);  
//        }
//    }
    //    String m_Sql = "";
    //    out.println("<table align=center width=100% cellPadding=0 cellSpacing=0>");
    //    out.println("<tr height=5px><td></td></tr>");
    //    m_Sql = "Select * from OA_MyCalendar where  UserID =" + m_strUserID + " and CalDate='" + m_strDate + "'";
    //    DBA.ExecuteQuery(m_Sql);
    //    for(; DBA.next(); out.println("</td></tr>"))
    //    {
    //        out.println("<tr>");
    //        if(DBA.getString("FinishFlag").equals("0"))
    //            out.println("<td width=14><img border=0 src='../images/crm_check.gif'></td>");
    //      else
    //            out.println("<td></td>");
    //        if(DBA.getString("Import").equals("0"))
    //            out.println("<td width=14><font color=red>★</font></td>");
    //       else
    //            out.println("<td></td>");
    //        out.println("<td style='font-size:12px;font-family:arial'>" + DBA.getString("StartTime"));
    //        out.println("&nbsp;");
    //        out.println("<a href='MyCalendarEdit.jsp?ID=" + DBA.getString("ID") + "'>" + DBA.getString("Title") + "</a>");
    //    }

    //    out.println("</table>");
   // }

    String cDay(int d)
    {
        String s;
        switch(d)
        {
        case 10: // '\n'
            s = "初十";
            break;

        case 20: // '\024'
            s = "二十";
            break;

        case 30: // '\036'
            s = "三十";
            break;

        default:
            s = nStr2[(int)Math.floor((double)(d / 10) * 1.0D)];
            s = s + nStr1[d % 10];
            break;
        }
        return s;
    }

    String cyclical(int num)
    {
        return Gan[num % 10] + Zhi[num % 12];
    }

    int lYearDays(int y)
    {
        int sum = 348;
        for(int i = 32768; i > 8; i >>= 1)
            sum += (lunarInfo[y - 1900] & i) <= 0 ? 0 : 1;

        return sum + leapDays(y);
    }

    int leapDays(int y)
    {
        if(leapMonth(y) > 0)
            return (lunarInfo[y - 1899] & 0xf) != 15 ? 29 : 30;
        else
            return 0;
    }

    int leapMonth(int y)
    {
        int lm = lunarInfo[y - 1900] & 0xf;
        return lm != 15 ? lm : 0;
    }

    int monthDays(int y, int m)
    {
        return (lunarInfo[y - 1900] & 0x10000 >> m) <= 0 ? 29 : 30;
    }
 
    int sTerm(int y, int n)
    {
        Date offDate = new Date(0x758f07a16L * (long)(y - 1900) + (long)(sTermInfo[n] * 60000) + Date.UTC(1900, 0, 6, 2, 5, 0));
        return offDate.getDate();
    }

    int solarDays(int y, int m)
    {
        if(m == 1)
            return (y % 4 != 0 || y % 100 == 0) && y % 400 != 0 ? 28 : 29;
        else
            return solarMonth[m];
    }

	public Date getTime() {
		// TODO 自动生成方法存根
		return null;
	}
}
